package org.zachary.commonservice.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.zachary.commonservice.entity.OverdueRecord;

@Mapper
public interface OverdueMapper {
    @Insert("INSERT INTO overdue_record (" +
            "uuid, user_id, service_type, is_overdue, " +
            "overdue_period, is_paid, amount, `desc`, due_time, finish_time" +
            ") VALUES (" +
            "#{uuid}, #{userId}, #{serviceType}, #{isOverdue}, " +
            "#{overduePeriod}, #{isPaid}, #{amount}, #{desc}, #{dueTime}, #{finishTime}" +
            ")")
    void storeOverdueRecord(OverdueRecord overdueRecord);
    @Select("SELECT * FROM overdue_record WHERE uuid=#{uuid}")
    OverdueRecord findByUuid(String uuid);

    @Update("UPDATE overdue_record SET overdue_period=#{overduePeriod}, is_paid=#{isPaid}, amount=#{amount}, `desc`=#{desc}, finish_time=#{finishTime} WHERE uuid=#{uuid}")
    void setFinished(OverdueRecord record);
}